package ZY11_1.Teacher;

public class Teacher {
     String name;
     int age;
     String school;

    public Teacher() {
    }

    public Teacher(String name, int age, String school) {
        this.name = name;
        this.age = age;
        this.school = school;
    }
    public void show(){
        jieshao();
        shangke();
    }
    public void jieshao(){
        System.out.printf("姓名:"+name+"年龄："+age+"来自"+school);
    }
    public void shangke(){
        System.out.println("我教的是java");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws Exception {

        if (age>22){
            this.age = age;
        }else {
            throw new Exception("年龄小于22异常");
        }
    }

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }
}
